//
//  HotAndGreatViewController.m
//  1gene
//
//  Created by 1jiyin on 16/4/29.
//  Copyright © 2016年 1jiyin. All rights reserved.
//

#import "HotAndGreatViewController.h"
#import "HotAndGreatTableView.h"
@interface HotAndGreatViewController ()<HotAndGreatTableViewDelegate>

@end

@implementation HotAndGreatViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:[UIView new]];
    self.view.backgroundColor=[UIColor whiteColor];
    [self createNavigation];
    [self createUI];
    // Do any additional setup after loading the view.
}
-(void)createUI
{
    HotAndGreatTableView *table=[[HotAndGreatTableView alloc]initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, self.view.frame.size.height-30) style:UITableViewStyleGrouped AndIndex:_selectedIndex];
    table.imgDelegate=self;
    [self.view addSubview:table];
}


//TableView的代理
-(void)bigImage:(NSInteger)currentIndex AndImageArrays:(NSArray *)imageArrays
{
    CommunityBigImageViewController *vc=[[CommunityBigImageViewController alloc]init];
    // vc.image=img;
    vc.navigationBarState=1;
    vc.imageArrays=[NSArray arrayWithArray:imageArrays];
    vc.currentIndex=currentIndex;
    [self.navigationController pushViewController:vc animated:YES];
}
-(void)gotoXiangQingViewController:(NSInteger)index
{
    TieBaXiangQingViewController *vc=[[TieBaXiangQingViewController alloc]init];
    vc.topic_id=index;
    vc.centerTag=4;
    //vc.arr=arr;
    [self.navigationController pushViewController:vc animated:YES];
}
-(void)chooseFunction:(NSInteger)index
{
    
}
-(void)gotoMyAttentionViewController:(NSString *)userId
{
    //我关注的
    MyAttentionViewController *vc=[[MyAttentionViewController alloc]init];
    vc.userId=userId;
    vc.barState=1;
    [self.navigationController pushViewController:vc animated:YES];
}


-(void)createNavigation
{
    self.navigationController.navigationBar.barTintColor=[UIColor colorWithRed:84/255.0 green:199/255.0 blue:222/255.0 alpha:1];
    //返回
    UIButton *leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame=CGRectMake(0, 0, 25, 25);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"left_back"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    
    //标题
    UILabel *title=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
    title.text=_myTitle;
    title.font=[UIFont systemFontOfSize:22];
    title.textAlignment=NSTextAlignmentCenter;
    title.textColor=[UIColor whiteColor];
    self.navigationItem.titleView=title;
}
//返回上一页
-(void)leftBtnClick:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)viewWillAppear:(BOOL)animated
{
    self.tabBarController.tabBar.hidden=YES;
    self.navigationController.navigationBar.hidden=NO;
    if (_translucentState) {
        [self.navigationController.navigationBar setTranslucent:YES];
    }
}

-(void)viewWillDisappear:(BOOL)animated
{
    if (_translucentState) {
        [self.navigationController.navigationBar setTranslucent:NO];
    }
}

@end
